package com.ly.mpayment.persist.service.errorcode;

import java.io.Serializable;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.ly.mpayment.persist.entity.ErrorCode;
import com.ly.mpayment.persist.hibernate.Page;
import com.ly.mpayment.persist.service.AbstractService;
@Service
public class ErrorCodeServiceImpl extends AbstractService<ErrorCode, Serializable> implements IErrorCodeService{

	@Override
	public boolean addErrorCode(ErrorCode code) {
		if(code != null){
			this.saveOrUpdate(code);
			return true;
		}
		return false;
	}

	@Override
	public boolean updateErrorCode(ErrorCode code) {
		if(code != null){
			this.saveOrUpdate(code);
			return true;
		}
		return false; 
	}

	@Override
	public ErrorCode findById(String id) {
		return this.findUnique("select e from ErrorCode e where e.status = 1 and  e.errorcode = ?", id);
	}

	@Override
	public Page<ErrorCode> findPageErrorCode(Map<String, Object> parameters, int start, int pageSize) {
		return this.findPageByNamed("select e from ErrorCode e where e.status = 1 #[and e.userByUseruuid.useruuid = :useruuid]#   #[and e.resultcode = :resultcode]#   order by e.errorname", parameters, start, pageSize);
	}

	@Override
	public ErrorCode findErrorCode(String resultcode) {
		return this.findUnique("select e from ErrorCode e where  e.resultcode = ?", resultcode);
	}

}
